package com.youngwang.annotation;

import java.lang.reflect.Method;

/**
 * @author youngwang
 *         Date: 2017/6/15
 */

@FieldMeta(name = "a")
public class AnnoTest {

    @FieldMeta(name = "b")
    public static void print(Class c){
        System.out.println(c.getName());

        FieldMeta fieldMeta = (FieldMeta) c.getAnnotation(FieldMeta.class);

        if( null != fieldMeta){
            System.out.println(fieldMeta.name());
        }

        Method[] methods = c.getMethods();
        for (Method m : methods){
            boolean isExistMethod = m.isAnnotationPresent(FieldMeta.class);
            if(isExistMethod){
                FieldMeta meta = m.getAnnotation(FieldMeta.class);
                System.out.println(meta.name());
            }
        }
    }

    public static void main(String[] args) {
        AnnoTest.print(AnnoTest.class);
    }
}
